<%--
  Created by IntelliJ IDEA.
  User: jqy
  Date: 2023/12/9
  Time: 17:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>

<html>
<head>
  <title>student</title>
  <style>
    .box {
      width: 1000px;
      /* 超出部分隐藏 */
      overflow: hidden;
      margin: auto;
      display: flex;
      background-color: #E1E9EF;
    }

    .content {
      width: 1000px;
      height: 600px;
      flex-shrink: 0;
    }

    .table11_3{
      width: 1000px;
      height: 600px;
    }
    .table11_3 table {
      margin:40px 20px;
      border:0;
    }
    .table11_3 th {
      background-color:#FF5675;
      color:#FFFFFF
    }
    .table11_3,.table11_3 th,.table11_3 td {
      font-size:0.95em;
      text-align:center;
      padding:4px;
      border-collapse:collapse;
    }
    .table11_3 th,.table11_3 td {
      border: 1px solid #fe2047;
      border-width:1px 0 1px 0;
      border:2px inset #ffffff;
    }
    .table11_3 tr {
      border: 1px solid #ffffff;
    }
    .table11_3 tr:nth-child(odd){
      background-color:#fec6d1;
    }
    .table11_3 tr:nth-child(even){
      background-color:#ffffff;
    }
  </style>
</head>
<body>

<section>
  <div class="box">
    <%
      Class.forName("com.mysql.jdbc.Driver");
      String url = "jdbc:mysql://localhost:3306/hospital";
      String name = "root";
      String password = "12345";
      request.setCharacterEncoding("UTF-8");
      Connection conn = DriverManager.getConnection(url, name, password);
      String patino = request.getParameter("Patino");
      String sql = "SELECT prescription.* FROM prescription WHERE prescr_pati_no = ?";
      PreparedStatement stmt = conn.prepareStatement(sql);
      stmt.setString(1, patino);
      ResultSet rs = stmt.executeQuery();
      String pati_name = new String();
      String prescr_medi = new String();
      String prescr_pati_no = new String();
      String doc_no = new String();
      String prescr_date = new String();
      String prescr_case_no = new String();
      int i = 0;
      while (rs.next()) {
        prescr_case_no = rs.getString("prescr_case_no");
        String ssql = "SELECT casea.case_pati_name FROM casea WHERE case_no = ?";
        PreparedStatement sstmt = conn.prepareStatement(ssql);
        sstmt.setString(1, prescr_case_no);
        ResultSet rrs = sstmt.executeQuery();
        while (rrs.next()) {
          pati_name = rrs.getString("case_pati_name");
        }
        rrs.close();
        sstmt.close();
        prescr_medi = rs.getString("prescr_medi");
        prescr_pati_no = rs.getString("prescr_pati_no");
        doc_no = rs.getString("presrc_doc_no");
        prescr_date = rs.getString("prescr_date");
        i++;
        String c = String.valueOf(i);
    %>
    <div id="<%=c%>" class="content">
      <table class=table11_3>
        <tr>
          <td>
            医生编号
          </td>
          <td>
            患者姓名
          </td>
          <td>
            患者身份证号
          </td>
          <td>
            用药情况
          </td>
          <td>
            开出时间
          </td>
          <td>
            所属病历号
          </td>
        </tr>
        <tr>
          <td>
            <%=doc_no%>
          </td>
          <td>
            <%=pati_name%>
          </td>
          <td>
            <%=prescr_pati_no%>
          </td>
          <td>
            <%=prescr_medi%>
          </td>
          <td>
            <%=prescr_date%>
          </td>
          <td>
            <%=prescr_case_no%>
          </td>
        </tr>
      </table>
    </div>
    <%
      }
    %>

  </div>
</section>
<%
  for (int j = 1; j <= i; j++) {
    StringBuilder sb = new StringBuilder();
    sb.append("#").append(String.valueOf(j));
    String c = new String(sb);
%>
<p><a href="<%=c%>" id="nav1"><%=c%>
</a></p>
<%
  }
  rs.close();
  stmt.close();
  conn.close();
%>
</body>
</html>

